package com.example.administrator.nurse.util;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.WindowManager;

import com.example.administrator.nurse.R;


/**
 * Created by elvinlee on 15/6/8.
 */

public class LoadingDialog extends Dialog {

    private static Context mContext;
    private static LoadingDialog loadingDialog = null;

    public LoadingDialog(Context context) {
        super(context);
        mContext = context;
    }

    public LoadingDialog(Context context, int theme) {
        super(context, theme);
    }

    public static LoadingDialog createDialog(Context context) {
        mContext = context;
        loadingDialog = new LoadingDialog(context, R.style.CustomProgressDialog);
        loadingDialog.setContentView(R.layout.loading_dialog);
        WindowManager.LayoutParams lp = loadingDialog.getWindow().getAttributes();
        lp.gravity = Gravity.CENTER;
        lp.alpha = 0.9f;  /** 在这里 设置 透明度 */
        loadingDialog.setCanceledOnTouchOutside(false);// 设置点击屏幕Dialog不消失
        loadingDialog.getWindow().setAttributes(lp);
        return loadingDialog;
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        if (loadingDialog == null) {
            return;
        }
//        ImageView imageView = (ImageView) loadingDialog.findViewById(R.id.loadingImageView);
//        AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getBackground();
//        animationDrawable.start();
    }
}
